import React from 'react'
import PropTypes from 'prop-types'
// import Search from 'material-ui-icons/Search'

import { withStyles } from 'material-ui/styles'
import categories from '../../constant/category'
import MoreMenu from '../more_menu/index'
import BgLine from '../bg_line/index'

import style from './style'

class TopicListInfo extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      category: categories,
    }
  }
  componentDidMount() {

  }
  getCurrentCategory() {
    const { tab } = this.props
    let category = {}
    categories.forEach((item) => {
      if (item.tab === tab) {
        category = item
      }
    })
    return category
  }
  render() {
    const category = this.getCurrentCategory()
    const Icon = category.icon
    const { classes } = this.props
    return (
      <div className={classes.infoWrap}>
        <div className={classes.info}>
          <div className={classes.container}>
            <Icon className={classes.icon} />
            <div className={classes.title}>{category.title}</div>
            <div className={classes.menu}>
              <MoreMenu />
            </div>
          </div>
          <BgLine />
        </div>
      </div>
    )
  }
}
export default withStyles(style)(TopicListInfo)

TopicListInfo.propTypes = {
  classes: PropTypes.objectOf(Object),
  tab: PropTypes.string,
}

